﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Cua_Hang.DTO;

namespace Cua_Hang
{
    public partial class ChiTiet_SanPham : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //this.HienThiSanPhamTheoChiTietCuaHang();
            this.hienphantrang();
        }
       
        void HienThiSanPhamTheoChiTietCuaHang()
        {
            //int ID_DanhMuc = int.Parse(Request.QueryString["ID_DanhMuc"]);
            //string ID_chitiet_cuahang1 = Request.QueryString["ID_chitiet_cuahang"];
           // ID_chitiet_cuahang = Convert.ToInt32(ID_chitiet_cuahang1);
           // DataList_ChiTiet_SanPham.DataSource = BUS.Cua_Hang_BUS.List_ChiTiet_SanPham_BUS(ID_chitiet_cuahang);
           // DataList_ChiTiet_SanPham.DataBind();

        }

        //------------------------------------
        void hienphantrang()
        {
            CollectionPager1.MaxPages = 10000;
            CollectionPager1.PageSize =4; // số items hiển thị trên một trang.
            CollectionPager1.DataSource = ConvertListChiTiet_SanPham_DTOToDataTable().DefaultView;
            CollectionPager1.BindToControl = DataList_ChiTiet_SanPham;
            DataList_ChiTiet_SanPham.DataSource = CollectionPager1.DataSourcePaged;
            DataList_ChiTiet_SanPham.DataBind();
        }
        //------------------------------------
        protected string getImageUrl(string image)
        {
            return "images/" + image;
        }

        //------------------------------------
        
        protected  DataTable ConvertListChiTiet_SanPham_DTOToDataTable()
        {
          
            
            List<ChiTiet_SanPham_DTO> lst = BUS.ChiTiet_SanPham_BUS.List_ChiTiet_SanPham_BUS(Convert.ToInt32(Request.QueryString["ID_chitiet_cuahang"]));
            DataTable dt = new DataTable();
            dt.Columns.Add("ID_ChiTiet_SanPham");
            dt.Columns.Add("Ten_ChiTiet_SanPham");
            dt.Columns.Add("ID_ChiTiet_CuaHang");
            dt.Columns.Add("Anh_ChiTiet_SanPham");
            dt.Columns.Add("Gia_ChiTiet_SanPham");
            dt.Columns.Add("ThongTin_ChiTiet_SanPham");
            dt.Columns.Add("GhiChu_ChiTiet_SanPham");
            for (int i = 0; i < lst.Count; i++)
            {
                dt.Rows.Add(
                        lst[i].ID_ChiTiet_SanPham,
                        lst[i].Ten_ChiTiet_SanPham,
                        lst[i].ID_ChiTiet_CuaHang,
                        lst[i].Anh_ChiTiet_SanPham,
                        lst[i].Gia_ChiTiet_SanPham,
                        lst[i].ThongTin_ChiTiet_SanPham,
                        lst[i].GhiChu_ChiTiet_SanPham

                    );
            }
            return dt;
        }

        protected void DataList_ChiTiet_SanPham_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        //------------------------------------
    }
}